@@ -79,10 +79,19 @@ def wx_order_create_api(request): |
||
79 | 79 |
except: |
80 | 80 |
continue |
81 | 81 |
amount = amount + good.price * g.get('num', 0) |
82 |
- |
|
82 |
+ |
|
83 | 83 |
if amount != total_fee: |
84 | 84 |
return response(OrderStatusCode.FEE_CHECK_FAIL) |
85 | 85 |
|
86 |
+ # 消库存 |
|
87 |
+ for g in goods_info: |
|
88 |
+ try: |
|
89 |
+ good = PackGoodsInfo.objects.get(pack_id=pack_id, good_id=g.get('good_id', '')) |
|
90 |
+ good.inventory -= g.get('num', 0) |
|
91 |
+ good.save() |
|
92 |
+ except PackGoodsInfo.DoesNotExist: |
|
93 |
+ continue |
|
94 |
+ |
|
86 | 95 |
# JSAPI--公众号支付、NATIVE--原生扫码支付、APP--app支付,统一下单接口trade_type的传参可参考这里 |
87 | 96 |
trade_type = 'JSAPI' |
88 | 97 |
|
@@ -152,7 +161,6 @@ def order_paid_success(order): |
||
152 | 161 |
try: |
153 | 162 |
good = PackGoodsInfo.objects.get(pack_id=order.pack_id, good_id=g.get('good_id', '')) |
154 | 163 |
good.has_sale_num += g.get('num', 0) |
155 |
- good.inventory -= g.get('num', 0) |
|
156 | 164 |
good.save() |
157 | 165 |
except PackGoodsInfo.DoesNotExist: |
158 | 166 |
continue |
@@ -165,6 +173,14 @@ def order_paid_fail(order): |
||
165 | 173 |
order.pay_status = OrderInfo.FAIL |
166 | 174 |
order.save() |
167 | 175 |
|
176 |
+ for g in order.goods_info: |
|
177 |
+ try: |
|
178 |
+ good = PackGoodsInfo.objects.get(pack_id=order.pack_id, good_id=g.get('good_id', '')) |
|
179 |
+ good.inventory += g.get('num', 0) |
|
180 |
+ good.save() |
|
181 |
+ except PackGoodsInfo.DoesNotExist: |
|
182 |
+ continue |
|
183 |
+ |
|
168 | 184 |
|
169 | 185 |
@logit |
170 | 186 |
@transaction.atomic |